package com.qj.yantaishan.controller;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qj.yantaishan.common.annotation.Log;
import com.qj.yantaishan.common.enums.BusinessType;
import com.qj.yantaishan.domain.StorePhysicalCourier;
import com.qj.yantaishan.service.IStorePhysicalCourierService;
import com.qj.yantaishan.common.core.controller.BaseController;
import com.qj.yantaishan.common.core.domain.AjaxResult;
import com.qj.yantaishan.common.utils.poi.ExcelUtil;
import com.qj.yantaishan.common.core.page.TableDataInfo;

/**
 * 本地化物流-配送员Controller
 * 
 * @author qihe
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/yantaishan/StorePhysicalCourier")
public class StorePhysicalCourierController extends BaseController
{
    private String prefix = "yantaishan/StorePhysicalCourier";

    @Autowired
    private IStorePhysicalCourierService storePhysicalCourierService;

    @RequiresPermissions("yantaishan:courier:view")
    @GetMapping()
    public String courier()
    {
        return prefix + "/courier";
    }

    /**
     * 查询本地化物流-配送员列表
     */
    @RequiresPermissions("yantaishan:courier:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StorePhysicalCourier storePhysicalCourier)
    {
        startPage();
        List<StorePhysicalCourier> list = storePhysicalCourierService.selectStorePhysicalCourierList(storePhysicalCourier);
        return getDataTable(list);
    }

    /**
     * 导出本地化物流-配送员列表
     */
    @RequiresPermissions("yantaishan:courier:export")
    @Log(title = "本地化物流-配送员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StorePhysicalCourier storePhysicalCourier)
    {
        List<StorePhysicalCourier> list = storePhysicalCourierService.selectStorePhysicalCourierList(storePhysicalCourier);
        ExcelUtil<StorePhysicalCourier> util = new ExcelUtil<StorePhysicalCourier>(StorePhysicalCourier.class);
        return util.exportExcel(list, "本地化物流-配送员数据");
    }

    /**
     * 新增本地化物流-配送员
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存本地化物流-配送员
     */
    @RequiresPermissions("yantaishan:courier:add")
    @Log(title = "本地化物流-配送员", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StorePhysicalCourier storePhysicalCourier)
    {
        return toAjax(storePhysicalCourierService.insertStorePhysicalCourier(storePhysicalCourier));
    }

    /**
     * 修改本地化物流-配送员
     */
    @RequiresPermissions("yantaishan:courier:edit")
    @GetMapping("/edit/{courierId}")
    public String edit(@PathVariable("courierId") Integer courierId, ModelMap mmap)
    {
        StorePhysicalCourier storePhysicalCourier = storePhysicalCourierService.selectStorePhysicalCourierByCourierId(courierId);
        mmap.put("storePhysicalCourier", storePhysicalCourier);
        return prefix + "/edit";
    }

    /**
     * 修改保存本地化物流-配送员
     */
    @RequiresPermissions("yantaishan:courier:edit")
    @Log(title = "本地化物流-配送员", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StorePhysicalCourier storePhysicalCourier)
    {
        return toAjax(storePhysicalCourierService.updateStorePhysicalCourier(storePhysicalCourier));
    }

    /**
     * 删除本地化物流-配送员
     */
    @RequiresPermissions("yantaishan:courier:remove")
    @Log(title = "本地化物流-配送员", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(storePhysicalCourierService.deleteStorePhysicalCourierByCourierIds(ids));
    }
}
